package com.shumm.controller;

import com.shumm.common.Result;
import com.shumm.po.Tcmrelation;
import com.shumm.service.TcmrelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author shumm
 * @Description
 * @create 2023-11-18 13:21
 */
@RestController
@RequestMapping("/tcmr")
@SuppressWarnings("all")
public class TcmrelationController {
    @Autowired
    private TcmrelationService service;

    @GetMapping("/listbc")
    private Result listByCondition(@RequestParam String name,
                                   @RequestParam String chuchu,
                                   @RequestParam String content,
                                   @RequestParam int num,
                                   @RequestParam int size
    ) {

        return service.listByCondition(name, chuchu, content, num, size);
    }


    @PostMapping("/add")
    private Result add(@RequestBody Tcmrelation tcmrelation) {
        return service.add(tcmrelation);
    }

    @GetMapping("/clist")
    public Result contentList() {
        return service.contentList();
    }

    @GetMapping("/list/{num}/{size}")
    public Result list(@PathVariable int num,
                       @PathVariable int size) {
        return service.list(num, size);
    }

    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable int id) {
        return service.deleteById(id);
    }

    @PostMapping("/update")
    public Result update(@RequestBody Tcmrelation tcmrelation) {
        return service.update(tcmrelation);
    }

    @GetMapping("/selectbyid")
    public Result selectById(@RequestParam int id) {
        return service.selectById(id);
    }
}
